package cc.vv.btpartyjob.partymanager.activity

import android.text.TextUtils
import cc.vv.baselibrary.bean.base.BaseResponseObj
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.jnimodule.server.OperationServer
import cc.vv.btpartyjob.partymanager.delegate.ManagerBaseBinder
import cc.vv.btpartyjob.partymanager.delegate.PartyRegisterDetailActivityDelegate
import cc.vv.btpartyjob.partymanager.moudel.resp.PartyReportDetailResponseObj
import cc.vv.btpartyjob.partymanager.server.PartyManagerServer
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder

/**
 * 党员报到详情
 * Created by Chen.qi on 2018/10/29.
 */
class PartyRegisterDetailActivity : BaseActivityMVP<PartyRegisterDetailActivityDelegate>() {

    override fun initData() {
        viewDelegate?.setTopBarTitle("详情")
        val id: String?
        try {
            id = intent.getStringExtra("id")
            if (!TextUtils.isEmpty(id)) {
                PartyManagerServer.partyReportList(id)
            }
        } catch (e: Exception) {
        }

    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }
        })

    }

    override fun getDelegateClass(): Class<PartyRegisterDetailActivityDelegate> {
        return PartyRegisterDetailActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return ManagerBaseBinder()
    }

    override fun getData(obj: BaseResponseObj<*>?) {
        super.getData(obj)
        when (obj) {
            is PartyReportDetailResponseObj -> {
                val data = obj.data
                viewDelegate?.setName(data?.name)
                viewDelegate?.setStreet(data?.street)
                viewDelegate?.setSheQu(data?.community)
                viewDelegate?.setPhone(data?.mobile)
                viewDelegate?.setZhiYe(data?.professionalCharacteristics)
                viewDelegate?.setWorkTime(OperationServer.formatStr(data?.workTime))
                viewDelegate?.setTeChang(data?.specialHobby)
                viewDelegate?.setChengNuo(data?.personalCommitment)
                viewDelegate?.setVolunteer(data?.volunteer)
            }
        }
    }
}